package com.baoyouqun.domain.Enum;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;

@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum HandleStatusEnum {
    REJECTED("0", "正常"),
    PROCESSED("-1", "已违规");

    @EnumValue // 标记数据库存储的字段
    private final String code;
    private final String desc;

    HandleStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // 根据 code 解析枚举
    public static HandleStatusEnum fromCode(String code) {
        for (HandleStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的处理状态：" + code);
    }
}